<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <#include "../common/header.ftl">

    <style>
        .modal-body img{
            width: 100%;
        }

        .modal-body{
            max-height: 500px;
            overflow-y: scroll;
        }
    </style>


    <script type="text/javascript">

        $(function(){
            $('#pagination').twbsPagination({
                totalPages:${result.pages} || 1,
                startPage:${result.pageNum},
                visiblePages:${result.pageSize},
                first:"首页",
                prev:"上页",
                next:"下页",
                last:"尾页",
                onPageClick:function(event, page){
                    //讲当前页设置page值
                    $("#currentPage").val(page);
                    //表单提交gjk,mb/.
                    $("#searchForm").submit();
                }
            });

            //查看文章内容
            $(".showContentBtn").click(function(){
                //获取游记的id
                var id= $(this).data("tid")
                $.get("/travel/getContentById.do",{id:id},function(data){
                    $(".modal-body").html(data.content)
                    $("#contentModal").modal('show')
                })
            })

            //发布 & 拒绝
            $(".changeSateBtn").click(function(){
                //获取游记的id
                var id = $(this).data("tid");
                //获取要修改的状态
                var state = $(this).data("state");
                $.get("/travel/changeState.do",{id:id,state:state},function(data){
                    if(data.success){
                        $.messager.confirm("温馨提示","操作成功!",function () {
                            window.location.reload();
                        })
                    }else{
                        $.messager.alert("错误信息",data.msg);
                    }
                })
            })
    	})
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待审核游记</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travelAudit/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入游记标题">
                </div>
                <div class="form-group">
                    <label for="state">状态:</label>
                    <select class="form-control" id="state" name="state">
                        <option value="-2">全部</option>
                        <option value="1">待发布</option>
                        <option value="-1">已拒绝</option>
                    </select>
                    <script>
                        $('#state option[value='+'${qo.state}'+']').prop('selected',true);
                    </script>
                </div>
                <button id="btn_query" class="btn btn-default">查询</button>

            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>

                        <th>编号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>地点</th>
                        <th>作者</th>
                        <th>状态</th>
                    </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${entity.title}</td>
                    <td><img src="${entity.coverUrl}" width="50px"/> </td>
                    <td>${(entity.place.name)!}</td>
                    <td>${(entity.author.nickName)!}</td>
                    <td>
                        <#if entity.state==-1>
                            拒绝
                        <#elseif entity.state==0>
                            草稿
                        <#elseif entity.state==1>
                            待发布
                        <#elseif entity.state==2>
                            已发布
                        </#if>
                    </td>
                    <td><a href="javascript:void(0);" class="changeSateBtn" data-state="2" data-tid='${entity.id}'>发布</a></td>
                    <td><a href="javascript:void(0);" class="changeSateBtn" data-state="-1" data-tid='${entity.id}'>拒绝</a></td>
                    <td><a href="javascript:void(0);" class="showContentBtn" data-tid='${entity.id}'>查看内容</a></td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="contentModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">查看游记内容</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
</html>